#include "clientTable.h"	

clientTable::clientTable()
{
	table;
}

bool clientTable::exists(char* checkIP, int checkInc, int checkCnum)
{
	for(int i = 0; i < table.size(); i ++)
		if( ((strcmp(table[i]->getIP(), checkIP) == 0)) && (table[i]->getInc() == checkInc) && (table[i]->getCnum() == checkCnum) )
			return true;
	return false;
}

tableEntry* clientTable::getEntry(char* checkIP, int checkInc, int checkCnum)
{
	for(int i = 0; i < table.size(); i ++)
		if( ((strcmp(table[i]->getIP(), checkIP) == 0)) && (table[i]->getInc() == checkInc) && (table[i]->getCnum() == checkCnum) )
			return table[i];
}

void clientTable::updateReq(char* checkIP, int cInc, int cNum, int newReq)
{
	for(int i = 0; i < table.size(); i ++)
		if( ((strcmp(table[i]->getIP(), checkIP) == 0)) && (table[i]->getInc() == cInc) && (table[i]->getCnum() == cNum) )
			table[i]->setReq(newReq);
}

void clientTable::addEntry(char* checkIP, int newInc, int newReq, int newCnum)
{
	tableEntry *newEntry = new tableEntry(checkIP, newInc, newReq, newCnum);
	table.push_back(newEntry);
}


